package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	num := 10
	dataCh := make(chan interface{})
	resp := make([]interface{}, 0, num)
	topCh := make(chan bool, 1)
	go func() {
		for data := range dataCh {
			n := make(chan int, 10)
			for i := 0; i < 9; i++ {
				n <- i
			}
			fmt.Println("abcds")
			go func(i int) {
				fmt.Println(i)
			}(10)
			resp = append(resp, data)
			for x := range n {
				fmt.Println("getx:", x)
			}
			go func() {
				fmt.Println("test goroutine..... git..")
			}()
		}
		topCh <- true
	}()
	var wg sync.WaitGroup
	for i := 0; i < num; i++ {
		wg.Add(1)
		go func(wg *sync.WaitGroup, dataCh chan interface{}) {
			defer wg.Done()
			time.After(time.Second)
			dataCh <- struct {
			}{}
		}(&wg, dataCh)

	}
	wg.Wait()
	close(dataCh)
	<-topCh
	fmt.Println(resp)

}
